<template>
    <div v-if="currentPage === 1" class="bg-#3f3f3f py-8px px-12px">
        <!-- 功能操作 -->
        <div class="mb-23px">
            <div class="text-12px font-bold mb-15px lh-12px">
                - 功能操作
            </div>
            <nut-button color="#d961b2" class="!w-full font-bold !border-none !h-30px !text-12px"
                @click="currentPage = 2">
                发布新公告
            </nut-button>
        </div>
        <!-- 编辑游戏公告 -->
        <div class="mb-17px">
            <div class="text-12px font-bold mb-15px lh-12px">
                - 编辑游戏公告
            </div>
            <n-select v-model="filterData.game_id" :columns="publisherStore.gameList" class="w-full"></n-select>
            <n-select v-model="filterData.status" :columns="[
                { text: '全部', value: -1 },
                { text: '待审核', value: 0 },
                { text: '上架', value: 1 },
                { text: '下架', value: 2 }
            ]" class="w-full my-14px"></n-select>

        </div>
        <!-- 列表 -->
        <div class="space-y-14px">
            <div v-for="item in noticeList" :key="item.id" class="px-6px py-10px bg-#232323 rounded-5px">
                <div class="flex gap-10px pb-9px mb-9px px-4px" style="border-bottom: 1px solid #3a3a3a;">
                    <div class="w-133px h-66px bg-pink">
                        img
                    </div>
                    <div class="flex flex-col justify-between">
                        <div class="flex justify-between lh-12px text-12px">
                            <span class="text-#d961b2">游戏更新</span>
                            <span class="font-bold">审核中</span>
                        </div>
                        <div class="text-9px font-bold lh-12px">
                            后宫英雄 - 3月12日游戏更新
                        </div>
                        <div class="text-7px text-#c0c0c0 lh-12px">
                            平行冒险——兔子是谁？世界 1 – 重新行动任务5“招聘2.0”“好吧，我们还等什么？
                        </div>
                        <div class="lh-12px text-9px">
                            <span>HAREM HEROES</span>
                            <span class="font-bold"> ‧ 20250/03/13</span>
                        </div>
                    </div>
                </div>
                <div class="flex justify-center items-center gap-6px">
                    <nut-button color="#d961b2" class="!w-132px !h-30px !text-12px font-bold">
                        修改
                    </nut-button>
                    <nut-button color="#000" class="!w-132px !h-30px !text-12px font-bold"
                        @click="deleteNotice(item.id)">
                        删除
                    </nut-button>
                </div>
            </div>
        </div>
    </div>
    <!-- 发布公告 -->
    <releaseNotice v-if="currentPage === 2" @back="currentPage = 1"></releaseNotice>
</template>

<script setup lang="ts">
import { TriangleDown } from '@nutui/icons-vue'
import { ref } from 'vue'
import releaseNotice from './releaseNotice.vue'
import NSelect from '@/components/common/NSelect.vue'
import { usePublisherStore } from '@/store/publisher'
import { axiosService } from '@/http/sever'
import { showNotify } from '@nutui/nutui'

const publisherStore = usePublisherStore()

const currentPage = ref(1)
const filterData = ref({
    'game_id': '',
    'status': '-1', //-1 全部 0待审核 1 上架 2下架
    'page': 1,
    'type': 1// 游戏更新 2限时活动
})
const noticeList = ref([])
const getNoticeList = () => {
    axiosService.post('/api/publisher/Bulletin/list', filterData.value).then(res => {
        console.log(' res -->', res)
    }).catch(err => {
        showNotify.danger(err.msg)
    })
}
getNoticeList()

// 删除
const deleteNotice = (id: number) => {
    axiosService.post('/api/publisher/Bulletin/delete', { id }).then(res => {
        console.log(' res -->', res)
    }).catch(err => {
        showNotify.danger(err.msg)
    })
}
</script>

<style scoped lang="scss">
:deep(.nut-input) {
    padding-top: 0px;
    padding-bottom: 0px;
    padding-left: 12px;
    padding-right: 12px;
    line-height: 30px;
}
</style>
